home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.3 / Video Toaster v4.3.iso / 3.1 / toasterall / arexx_examples / tpaint / tpmap.rexx < prev    next >
OS/2 REXX Batch file  |  1992-01-29  |  4KB  |  121 lines

  1. /* TPMap.rexx -- Make texture map images for LightWave with edges that match */
  2. /* By Arnie Cachelin © 1992 NewTek Inc.                                      */
  3.  
  4. /*
  5.     This program will create an image which has matching left and right edges,
  6.     and top and bottom edges for use as texture maps in LightWave3D.  The
  7.     program will cut a strip off the top of an image, flip it over, and
  8.     paste it on the bottom edge with transparency set to blend the inner side
  9.     of the brush smoothly into the image.  It then repeats this process for
  10.     a strip on the left side.  To use the program, makesure TPaint is
  11.     running, rexx is installed and this script is in the current directory
  12.     or in 'REXX:'.  From a shell, simply type 'rx TPMap'.  Optional
  13.     arguments specify a width for the strips that will be cut, an input
  14.     file name for an RGB image to load, and an output filename.  If no
  15.     width is given, 128 is used, which works pretty well.  If no in file is
  16.     given, the current paint canvas is used. If an input file is given, the
  17.     result is saved with .map appended.
  18. */
  19.  
  20.  
  21. ARG dist infile outfile
  22. PageWide=752
  23. PageHigh=480
  24.  
  25. if pos('DigiPaint',show(ports))=0 then do
  26.   say "Can't find ToasterPaint!"
  27.   exit
  28. end
  29.  
  30. Address "DigiPaint"     /* Tell ARexx where commands go  */
  31.  
  32. if dist="" then dist=128
  33. if infile~="" then do
  34.   if ~exists(infile) then do
  35.     say "Can't find input image file "infile
  36.     exit
  37.   end
  38.   if outfile="" then outfile=infile".map"
  39.   Call LoadRGB(infile) /* if no name is given, use current screen! */
  40. end
  41.  
  42. 'Pmcl'          /* Set to normal paint mode */
  43. Call CutBrush(0,0,PageWide,dist)   /*  Cut brush along top */
  44. 'Fliy'          /* Flip about x axis (reverse y) */
  45. 'Varr'          /* Set to vertical gradient blend */
  46. 'Potv' 0        /* Set hotspot at top */
  47. 'Minc'          /* Set Center transparency to 0% */
  48. 'Maxe'          /* Set Edge transparency to 100% */
  49. 'Pend' PageWide/2 PageHigh-dist/2 /* Place brush */
  50. 'Penu' PageWide/2 PageHigh-dist/2
  51. Call CutBrush(0,0,dist,PageHigh)   /* cut brush along left side */
  52. 'Flix'          /* Flip about y axis (reverse x) */
  53. 'Harr'          /* Set to Horizontal gradient blend */
  54. 'Potv' 0        /* Set hotspot at left edge */
  55. 'Minc'          /* Set Center transparency to 0% */
  56. 'Maxe'          /* Set Edge transparency to 100% */
  57. 'Pend' PageWide-dist/2 PageHigh/2 /* Place brush */
  58. 'Penu' PageWide-dist/2 PageHigh/2
  59. 'Shco'
  60. if outfile~="" then Call SaveRGB(outfile) /* if no name is given, use current screen! */
  61. exit
  62.  
  63. CutBrush: PROCEDURE  /* Cut out a brush with corners at (x1,y1) and (x2,y2) */
  64.   arg x1, y1, x2, y2
  65.   'Dotb'        /* smallest brush size */
  66.   'Drre'        /* Rectangle mode  */
  67.   'Scis'        /* Scissors on, for cutting a brush  */
  68.   'Pend' x1 y1  /* Get in top Left corner  */
  69.   'Penu' x2 y2  /* lift pen to get brush!  */
  70.   return 0
  71.  
  72. SetFile: PROCEDURE           /* Select file in current requester */
  73.   arg file
  74.   dirname=GetPathName(file)
  75.   'Dnam'dirname          /* Enter file path  */
  76.   'Dsel'                 /* Hit return on directory */
  77.   filename=GetFileName(file)
  78.   'Fnam'filename         /* Enter File name  */
  79.   'Okls'                 /* Hit the OK button  */
  80.   return
  81.  
  82. LoadFrameStore: PROCEDURE   /* Load FrameStore */
  83.   arg filename           /* must have ###.fs on front! */
  84.   'Loco'                 /* Call file requester  */
  85.   'Fnam'filename         /* Enter File name  */
  86.   'Okls'                 /* Hit the OK button  */
  87.   return 0
  88.  
  89. SaveFrameStore: PROCEDURE   /* Save FrameStore */
  90.   arg filename           /* must have ###.fs on front! */
  91.   'Saco'                 /* Call file requester  */
  92.   'Fnam'filename         /* Enter File name  */
  93.   'Okls'                 /* Hit the OK button  */
  94.   return 0
  95.  
  96. LoadRGB: PROCEDURE   /* Load IFF RGB, copy into swap buffer */
  97.   arg filename
  98.   'Lo24'                 /* Call file requester  */
  99.     Call SetFile(filename)
  100.   return
  101.  
  102. SaveRGB: PROCEDURE   /* Save IFF RGB, copy into swap buffer */
  103.   arg filename
  104.   'Sa24'                 /* Call file requester  */
  105.     Call SetFile(filename)
  106.   return
  107.  
  108. GetFileName: procedure  /* Extract file name from full file specification */
  109.   ARG fullfile
  110.   c = lastpos("/",fullfile)
  111.   if c = 0 then c = lastpos(":",fullfile)
  112.   return substr(fullfile, c + 1)
  113.  
  114. GetPathName: procedure  /* Extract directory name from full file specification */
  115.   ARG fullfile
  116.   c = lastpos("/",fullfile)
  117.   if c = 0 then c = lastpos(":",fullfile)
  118.   return left(fullfile,c)
  119.  
  120.  
  121.